﻿var appName = "OSharpApp";
angular.module(appName, ["kendo.directives"]).controller("app.admin.store.products", ["$scope", function ($scope) {
    $scope.title = "商品信息列表";
    $scope.gridOptions = $.osharp.kendo.grid.Options({
        url: {
            read: "/admin/products/read",
            create: "/admin/products/create",
            update: "/admin/products/update",
            destroy: "/admin/products/delete"
        },
        model: {
            id: "Id",
            fields: {
                Id: { type: "number", editable: false },
                Name: { type: "string", validation: { required: true } },
                ProductType: { type: "number", validation: { required: true } },
                Count: { type: "number", editable: false },
                Milage: { type: "number", validation: { min: 0 } },
                CreatedTime: { type: "date", editable: false }
            }
        },
        columns: [
            { command: [{ name: "destroy", text: "" }], width: 50 },
            { field: "Id", title: "编号", width: 75 },
            { field: "Name", title: "商品名称" },
            {
                field: "ProductType", title: "商品类型",
                editor: function (container, options) {
                    $.osharp.kendo.grid.DropDownListEditor(container, options, $.osharp.data.admin.productTypes);
                },
                template: function (d) { return $.osharp.tools.valueToText(d.ProductType, $.osharp.data.admin.productTypes); }
            },
            { field: "Milage", title: "使用里程数" },
            { field: "Count", title: "库存数量" },
            { field: "CreatedTime", title: "添加时间", format: "{0: yyyy-MM-dd HH:mm}" }
        ]
    });
}]);